home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / OS / FWGraphx / Sources / FWPicShp.cpp < prev    next >
Encoding:
Text File  |  1996-04-25  |  5.7 KB  |  205 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWPicShp.cpp
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWOS.hpp"
  11.  
  12. #ifndef FWPICSHP_H
  13. #include "FWPicShp.h"
  14. #endif
  15.  
  16. #ifndef FWGC_H
  17. #include "FWGC.h"
  18. #endif
  19.  
  20. #ifndef SLGRGLOB_H
  21. #include "SLGrGlob.h"
  22. #endif
  23.  
  24. #ifndef FWBMPSHP_H
  25. #include "FWBmpShp.h"
  26. #endif
  27.  
  28. #ifndef FWRECT_H
  29. #include "FWRect.h"
  30. #endif
  31.  
  32. #ifndef SLRENDER_H
  33. #include "SLRender.h"
  34. #endif
  35.  
  36. // ----- Foundation Includes -----
  37.  
  38. #ifndef FWSTREAM_H
  39. #include "FWStream.h"
  40. #endif
  41.  
  42. #ifndef FWDEBUG_H
  43. #include "FWDebug.h"
  44. #endif
  45.  
  46. #ifndef FWMEMORY_H
  47. #include "FWMemory.h"
  48. #endif
  49.  
  50. //========================================================================================
  51. // File scope definitions
  52. //========================================================================================
  53.  
  54. #if defined(__MWERKS__) && GENERATING68K
  55. // A hack to work around a bug
  56. #pragma import list somGetGlobalEnvironment
  57. #endif
  58.  
  59. #ifdef FW_BUILD_MAC
  60. #pragma segment FWGraphics_PictureShape
  61. #endif
  62.  
  63. //========================================================================================
  64. //    class FW_CPictureShape
  65. //========================================================================================
  66.  
  67. FW_DEFINE_AUTO(FW_CPictureShape)
  68. FW_DEFINE_CLASS_M1(FW_CPictureShape, FW_CBoundedShape)
  69.  
  70. // This class is archivable, but we provide the archiving implementation in a separate
  71. // translation unit in order to enable deadstripping of the archiving-related code
  72. // in parts that do not use archiving with this class.
  73.  
  74. //----------------------------------------------------------------------------------------
  75. //    FW_CPictureShape::FW_CPictureShape
  76. //----------------------------------------------------------------------------------------
  77.  
  78. FW_CPictureShape::FW_CPictureShape(FW_CPicture picture, const FW_CRect& rect) :
  79.     FW_CBoundedShape(rect, FW_kFill, FW_kNormalInk, FW_kNormalStyle, FW_kNormalFont),
  80.     fPicture(picture)
  81. {
  82.     FW_END_CONSTRUCTOR
  83. }
  84.  
  85. //----------------------------------------------------------------------------------------
  86. //    FW_CPictureShape::FW_CPictureShape
  87. //----------------------------------------------------------------------------------------
  88.  
  89. FW_CPictureShape::FW_CPictureShape(const FW_CPictureShape& other) :
  90.     FW_CBoundedShape(other),
  91.     fPicture(other.fPicture)
  92. {
  93.     FW_END_CONSTRUCTOR
  94. }
  95.  
  96. //----------------------------------------------------------------------------------------
  97. //    FW_CPictureShape::FW_CPictureShape
  98. //----------------------------------------------------------------------------------------
  99.  
  100. FW_CPictureShape::FW_CPictureShape(FW_CReadableStream& stream) :
  101.     FW_CBoundedShape(stream),
  102.     fPicture()
  103. {
  104.     stream >> fPicture;
  105.     
  106.     FW_END_CONSTRUCTOR
  107. }
  108.  
  109. //----------------------------------------------------------------------------------------
  110. //    FW_CPictureShape::~FW_CPictureShape
  111. //----------------------------------------------------------------------------------------
  112.  
  113. FW_CPictureShape::~FW_CPictureShape()
  114. {
  115.     FW_START_DESTRUCTOR
  116. }
  117.  
  118. //----------------------------------------------------------------------------------------
  119. //    FW_CPictureShape::operator=
  120. //----------------------------------------------------------------------------------------
  121.  
  122. FW_CPictureShape& FW_CPictureShape::operator=(const FW_CPictureShape& other)
  123. {
  124.     if (this != &other)
  125.     {
  126.         FW_CBoundedShape::operator=(other);
  127.     
  128.         fPicture = other.fPicture;
  129.     }
  130.     
  131.     return *this;
  132. }
  133.  
  134. //----------------------------------------------------------------------------------------
  135. //    FW_CPictureShape::Render
  136. //----------------------------------------------------------------------------------------
  137.  
  138. void FW_CPictureShape::Render(FW_CGraphicContext& gc) const
  139. {
  140.     FW_PrivRenderPicture(gc.GetEnvironment(),
  141.         gc,
  142.         fPicture,
  143.         fRect,
  144.         GetRenderVerb());
  145.     FW_FailOnEvError(gc.GetEnvironment());
  146. }
  147.  
  148. //----------------------------------------------------------------------------------------
  149. //    FW_CPictureShape::RenderPicture
  150. //----------------------------------------------------------------------------------------
  151.  
  152. void FW_CPictureShape::RenderPicture(FW_CGraphicContext& gc,
  153.                                     FW_CPicture picture,
  154.                                     const FW_CRect& dstRect)
  155. {
  156.     FW_PrivRenderPicture(gc.GetEnvironment(),
  157.         gc,
  158.         picture,
  159.         dstRect,
  160.         FW_kFill);
  161.     FW_FailOnEvError(gc.GetEnvironment());
  162. }
  163.  
  164. //----------------------------------------------------------------------------------------
  165. //    FW_CPictureShape::GetGeometry
  166. //----------------------------------------------------------------------------------------
  167.  
  168. void FW_CPictureShape::GetGeometry(FW_CPicture& picture, FW_CRect& dstRect) const
  169. {
  170.     picture = fPicture;
  171.     dstRect = fRect;
  172. }
  173.  
  174. //----------------------------------------------------------------------------------------
  175. //    FW_CPictureShape::SetGeometry
  176. //----------------------------------------------------------------------------------------
  177.  
  178. void FW_CPictureShape::SetGeometry(const FW_CPicture& picture, const FW_CRect& dstRect)
  179. {
  180.     fPicture = picture;
  181.     fRect = dstRect;
  182. }
  183.  
  184. //----------------------------------------------------------------------------------------
  185. //    FW_CPictureShape::Flatten
  186. //----------------------------------------------------------------------------------------
  187.  
  188. void FW_CPictureShape::Flatten(FW_CWritableStream& stream) const
  189. {
  190.     FW_CBoundedShape::Flatten(stream);
  191.  
  192.     Environment* ev = somGetGlobalEnvironment();
  193.     stream << fPicture;
  194. }
  195.  
  196. //----------------------------------------------------------------------------------------
  197. //    FW_CPictureShape::Copy
  198. //----------------------------------------------------------------------------------------
  199.  
  200. FW_CShape* FW_CPictureShape::Copy() const
  201. {
  202.     return FW_NEW(FW_CPictureShape, (*this));
  203. }
  204.  
  205.